{literal}
<script type="text/javascript" language="javascript">
var urlEditar = '{/literal}{$_site.url}{$urlEditar}{literal}';
var urlApagar = '{/literal}{$_site.url}{$urlApagar}{literal}';
function irPara(pag)
{
	document.form_busca.pag.value = pag;
	jqAjaxForm(document.form_busca, "div_tabela");
}
function anterior()
{
	irPara(parseInt(document.form_busca.pag.value)-1);
}
function proximo()
{
	irPara(parseInt(document.form_busca.pag.value)+1);
}
function editar(codigo)
{
	document.form_acao.action = urlEditar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "editar";
	jqAjaxForm(document.form_acao, "div_form");
}
function excluir(codigo)
{
	document.form_acao.action = urlApagar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "apagar";
	jqAjaxForm(document.form_acao, "div_form");
}
$(document).ready(function () {
	populaSelect("busca_perfil", "{/literal}{$_site.url}{literal}", "perfil/select-perfil?cod={/literal}{$busca_perfil}{literal}");
});$("#lnkGerarCSV").click(function(){	var params = $("#form_busca").serialize();	window.location.href = "pre-atendimento/gerar-csv/?" + params;});$("#data_inicio").datepick({showOn: 'both'});$("#data_fim").datepick({showOn: 'both'});$("#data_inicio").mask("99/99/9999");$("#data_fim").mask("99/99/9999");
</script>
{/literal}

	<form name="form_acao" id="form_acao" action="#" method="post">
		<input type="hidden" name="codigo" id="codigo" value=""/>
		<input type="hidden" name="acao" id="acao" value=""/>
	</form>
	
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2" class="alpha">
      <tr>
        <td colspan="7" class="mvTituloFundo">Pr&eacute;-atendimentos</td>
      </tr>	  <tr>        <td colspan="7" align="center">	        <form name="form_busca" id="form_busca" action="{$_site.url}pre-atendimento/tabela" method="post" onsubmit="irPara(document.form_busca.pag.value); return false;">	        	<table width="100%">	        		<tr>	        			<td class="fundoTituloForm bordaFormResp" width="15%">Nome cliente</td>	        			<td class="bordaFormResp" width="35%"><input type="text" size="3" name="nome" id=nome" value="{$nome}" class="formulario tamanhoForm"/></td>	        			<td class="fundoTituloForm bordaFormResp" width="15%">Per&iacute;odo</td>	        			<td class="bordaFormResp" width="35%" colspan="3">de:&nbsp;<input type="text" name="data_inicio" id="data_inicio" class="formulario" size="10" value="{$data_inicio}">&nbsp;&nbsp;&agrave;:&nbsp;<input type="text" name="data_fim" id="data_fim" class="formulario" size="10" value="{$data_fim}"></td>	        		</tr>	 				<tr>                 		<td valign="top" class="bordaFormResp" colspan="6" align="center"><input type="submit" value="Buscar" class="botao"/></td>					</tr>	        	</table>	        					<input type="hidden" name="pag" id="pag" value="{$pag}"/>			</form>		</td>      </tr>
      <tr>
        <td colspan="7" align="center">        	<div style="width:100%; postion:relative">	        	<div style="text-align:center; width:85%; float:left"><b>{$total}</b> encontrados, exibindo de <b>{$inicio}</b> a <b>{$fim}</b></div>	        	<div style="text-align:right; width:15%; float:right"><span id="lnkGerarCSV"><b>Exportar para</b> &nbsp;<img src="{$_site.url}/public/images/ic-xls.gif" border="0" align='top' style="cursor:pointer">&nbsp;</span></div>        	</div>		</td>
      </tr>
      <tr>
        <td width="20%" valign="top" class="paddingTotal3 bgCarla bold">Nome</td>        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold">Data</td>        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold">E-mail</td>        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold">Telefone</td>        <td width="50%" valign="top" class="paddingTotal3 bgCarla bold">Descri&ccedil;&atilde;o</td>
        <td width="" colspan="2" align="center" valign="top" class="paddingTotal3 bgCarla bold">A&ccedil;&atilde;o</td>
      </tr>
      {foreach name=lista from=$preatendimentos item=preatendimento}
      <tr>
        <td valign="top" class="fundoTituloForm">{$preatendimento->vhr_nome}</td>        <td valign="top" class="fundoTituloForm">{$preatendimento->dte_data|ConverteData:5}</td>        <td valign="top" class="fundoTituloForm">{$preatendimento->vhr_email}</td>        <td valign="top" class="fundoTituloForm">{$preatendimento->vhr_telefone}</td>        <td valign="top" class="fundoTituloForm">{$preatendimento->vhr_descricao}</td>
        <td width="1%" align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="editar('{$preatendimento->id}'); return false;"><img src="{$_site.url}public/images/ic-cadastrar.gif" alt="Alterar" border="0" title="Alterar"/></a></td>
        <td width="1%" align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="excluir('{$preatendimento->id}'); return false;"><img src="{$_site.url}public/images/ic-excluir.gif" alt="Excluir" border="0" title="Excluir"/></a></td>
      </tr>
      {/foreach}
      <tr>
        <td colspan="7" align="center">{if $pag gt 1}
		<a href="#" onclick="irPara('1'); return false;"><<</a> 
		<a href="#" onclick="anterior(); return false;"><</a> 
	{else}
		<<  < 
	{/if}
	{section name=foo start=1 loop=$totalPag+1}
		{if $smarty.section.foo.index eq $pag}
			<font color="red">{$smarty.section.foo.index}</font>
		{else}
			<a href="#" onclick="irPara('{$smarty.section.foo.index}'); return false;">{$smarty.section.foo.index}</a>
		{/if}
		{if $smarty.section.foo.index lt $totalPag}
		|
		{/if}
	{/section}
	{if $pag lt $totalPag}
	<a href="#" onclick="proximo(); return false;">></a> 
	<a href="#" onclick="irPara('{$totalPag}'); return false;">>></a>
	{else}
	>  >>
	{/if}</td>
      </tr>
    </table>
